package com.example.spinning.service;

import com.example.spinning.bean.MaterialQuality;
import com.example.spinning.bean.SemiQuality;
import com.example.spinning.mapper.SemiQualityMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Date;
import java.sql.Timestamp;
import java.util.List;


@Service
@Transactional
public class SemiQualityService {
    @Autowired
    SemiQualityMapper semiQualityMapper;


    //增加操作
    public int addNewSemiQuality(SemiQuality semiQuality) {
        return semiQualityMapper.addNewSemiQuality(semiQuality);
    }

    //删除操作
    public boolean deleteSemiQualityById(Long[] ids) {
        int result = semiQualityMapper.deleteSemiQualityById(ids);
        return result == ids.length;
    }

    //查询并分页
    public PageInfo<SemiQuality> findPage(Integer page, Integer size, String batch_no,String name, Date date) {

        SemiQuality semiQuality = new SemiQuality();
        semiQuality.setBatch_no(batch_no);
        semiQuality.setName(name);
        semiQuality.setDate(date);

        PageHelper.startPage(page,size);
        List<SemiQuality> list = semiQualityMapper.select(semiQuality);
        PageInfo<SemiQuality> pageInfo = new PageInfo<>(list);

        return pageInfo;
    }
    //动态修改
    public int  updateCategoryById(SemiQuality semiQuality){
        int result = semiQualityMapper.updateByPrimaryKeySelective(semiQuality);
        return result;
    }



}
